Ext.define('Admin.app.BaseController', {
			extend : 'Ext.app.ViewController',

			getMain : function() {
				return Admin.getApplication().getMainView().refs.mainct;
			},

			getUser : function() {
				return this.getViewModel().get('user');
			},

			getOrg : function() {
				return this.getUser().org;
			},

			getCr : function() {
				return this.getViewModel().get('record');
			},

			onParamsChange : function(cmp, newValue, oldValue, eOpts) {
				var me = this, vm = me.getViewModel(), view = me.getView(), record = vm.get('record');
				if (view.isVisible() && cmp.isVisible() && record) { // 判断isVisible()，防止页面未构建但是因为赋初值而误动作
					// debugger;
					var params = {};
					params[cmp.getBind().value.stub.name] = newValue;
					view.fireEvent('refresh', view, record, params);
				}
			},

			refreshView : function(view) {
				var store = view.getStore && view.getStore(), data, reloads = [];
				if (store) {
					store.reload();
				} else {
					var views = view.query('*[getStore]'), len = views.length;
					for (i = 0; i < len; i++) {
						store = views[i].getStore();
						if (store) {
							data = store.config.data;
							if (data && data.length) { // 本地store
								continue;
							}
							if (-1 == reloads.indexOf(store.getId())) {
								reloads.push(store.getId());
								store.reload();
							}
						}
					}
				}
			},

			onRefreshDefault : function(view, record, params) {
				this.refreshView(view);
			},

			onRefreshClick : function() {
				var me = this;
				me.onRefreshDefault(me.getView(), me.getCr(), null);
			},

			onExportClick : function() {
				var view = this.getView(), table = view.queryById('pivot');
				table.saveDocumentAs({
							type : 'excel07',
							title : table.pivotName,
							author : 'SEQDATA',
							fileName : table.pivotName + '.xlsx'
						});
			},

			onBeforeDocumentSave : function(view) {
				view.mask('正在准备导出数据，请稍后......');
			},

			onDocumentSave : function(view) {
				view.unmask();
			}

		});